package qlsl.androiddesign.adapter.subadapter;

import java.util.List;

import com.qlsl.androiddesign.kuaiwa.R;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import qlsl.androiddesign.activity.baseactivity.BaseActivity;
import qlsl.androiddesign.adapter.baseadapter.BaseAdapter;
import qlsl.androiddesign.entity.otherentity.ShoppingDetail;
import qlsl.androiddesign.util.commonutil.ImageUtils;
import qlsl.androiddesign.util.commonutil.TextSizeUtils;
import qlsl.androiddesign.util.commonutil.TimeFormatUtils;

/**
 * 订单列表<br/>
 * 
 */
public class CoinOrderAdapter extends BaseAdapter<ShoppingDetail> {

	public CoinOrderAdapter(BaseActivity activity, List<ShoppingDetail> list) {
		super(activity, list);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = getItemView(convertView, R.layout.listitem_coin_order);

		ImageView iv_icon = getView(convertView, R.id.iv_icon);
		TextView tv_name = getView(convertView, R.id.tv_name);
		TextView tv_time = getView(convertView, R.id.tv_time);
		TextView tv_price_sell = getView(convertView, R.id.tv_price_sell);
		TextView tv_state = getView(convertView, R.id.tv_state);
		TextView tv_total = getView(convertView, R.id.tv_total);

		ShoppingDetail item = getItem(position);
		String name = item.getGoodsname();
		String num = "1";
		String points = item.getPoints() + "挖币";
		String time = item.getTime();
		String space = activity.getString(R.string.space);

		ImageUtils.rectOri(activity, item.getPhoto(), iv_icon);
		tv_name.setText(name);
		tv_time.setText(TimeFormatUtils.format(time));
		tv_state.setText("已支付");
		TextSizeUtils.setText(tv_price_sell, points, 0, points.length(), 14,
				activity.getResources().getColor(R.color.half_red));
		tv_total.setText("共" + num + "件商品" + space + "合计：" + points);

		return convertView;
	}
}
